class RequestBean {
  id: string;
  url: string;
  method: string;
  createTime: Date;
  headers: Record<string, string>;
  body: any;

  constructor(
    id: string,
    url: string,
    method: string,
    createTime: Date,
    headers: Record<string, string>,
    body: any
  ) {
    this.id = id;
    this.url = url;
    this.method = method;
    this.createTime = createTime;
    this.headers = headers;
    this.body = body;
  }

  toJson(): Record<string, any> {
    return {
      id: this.id,
      url: this.url,
      method: this.method,
      createTime: this.createTime.toISOString(),
      headers: this.headers,
      body: this.body,
    };
  }

  static fromJson(json: Record<string, any>): RequestBean {
    return new RequestBean(
      json['id'],
      json['url'],
      json['method'],
      new Date(json['createTime']),
      json['headers'],
      json['body']
    );
  }
}

export default RequestBean;
